package us.gaaoc.framework.dao;


import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.hibernate.Session;

import us.gaaoc.framework.businessmodel.Filing;
import us.gaaoc.framework.model.Address;
import us.gaaoc.framework.model.AddressCategory;
import us.gaaoc.framework.model.AddressType;
import us.gaaoc.framework.model.Attorney;
import us.gaaoc.framework.model.CaseRecord;
import us.gaaoc.framework.model.CaseRecordAction;
import us.gaaoc.framework.model.CaseRecordEventType;
import us.gaaoc.framework.model.CaseRecordHistory;
import us.gaaoc.framework.model.CaseRecordIdExternalCaseRecordNumber;
import us.gaaoc.framework.model.CaseRecordStatus;
import us.gaaoc.framework.model.CaseRecordType;
import us.gaaoc.framework.model.Counter;
import us.gaaoc.framework.model.CounterPerSigner;
import us.gaaoc.framework.model.Court;
import us.gaaoc.framework.model.CourtEventType;
import us.gaaoc.framework.model.CourtEvents;
import us.gaaoc.framework.model.CourtHearingNegotiations;
import us.gaaoc.framework.model.CourtSeal;
import us.gaaoc.framework.model.DocPageRange;
import us.gaaoc.framework.model.DocumentBinaries;
import us.gaaoc.framework.model.DocumentInstance;
import us.gaaoc.framework.model.DocumentLocalCode;
import us.gaaoc.framework.model.DocumentPackage;
import us.gaaoc.framework.model.DocumentSigConfig;
import us.gaaoc.framework.model.DocumentStatus;
import us.gaaoc.framework.model.DocumentType;
import us.gaaoc.framework.model.Documents;
import us.gaaoc.framework.model.FilingAudit;
import us.gaaoc.framework.model.FilingSearch;
import us.gaaoc.framework.model.LdapDirectoryOrganization;
import us.gaaoc.framework.model.LdapDirectoryPerson;
import us.gaaoc.framework.model.LegalPreparer;
import us.gaaoc.framework.model.LocalCaseCategory;
import us.gaaoc.framework.model.LocalCaseDivision;
import us.gaaoc.framework.model.LocalCaseFilingType;
import us.gaaoc.framework.model.LocalCaseType;
import us.gaaoc.framework.model.LocalCourtEventType;
import us.gaaoc.framework.model.LocalParticipantRelationship;
import us.gaaoc.framework.model.OrgParticipants;
import us.gaaoc.framework.model.OrganizationAddress;
import us.gaaoc.framework.model.Organizations;
import us.gaaoc.framework.model.ParticipantRelationship;
import us.gaaoc.framework.model.Person;
import us.gaaoc.framework.model.PersonAddress;
import us.gaaoc.framework.model.PersonHashedSSN;
import us.gaaoc.framework.model.PersonOrganizations;
import us.gaaoc.framework.model.PersonParticipants;
import us.gaaoc.framework.model.Profile;
import us.gaaoc.framework.model.Roles;
import us.gaaoc.framework.model.SignatureImage;
import us.gaaoc.framework.model.Signatures;
import us.gaaoc.framework.model.VisualMark;
import us.gaaoc.framework.model.VisualMarkCategory;
import us.gaaoc.framework.model.util.CaseRecordsCountPerDay;
import us.gaaoc.framework.model.util.CaseRecordsCountPerMonth;
import us.gaaoc.framework.model.util.DismissedCases;
import us.gaaoc.framework.model.util.DismissedCasesPerMonth;
import us.gaaoc.framework.model.util.DocumentsCountByType;
import us.gaaoc.framework.model.util.DocumentsCountPerMonth;

public interface ModelFacade {

	public Session getSession();
	
	/* Person Access */
	public abstract Person findPersonById(String uuid);
	//returns the Person of the given username and password
	public abstract Person login(String username, String password);
	public abstract Person getPersonByUserName(String username);
	public abstract Profile getPersonProfileByEmail(String email);
	public abstract Person makePersistent(Person person);
	//returns List of the Person
	public abstract List<Person> getAllPeople();
	//returns List of the Non deleted Person
	public abstract List<Person> getNonDeletedPerson();
	/* Commented By: Ramu (eppakayr)
	 * public abstract List<Person> getNonDeletedPersonWithNonNullUserId();
	 * */
	public abstract List<Person> getNonDeletedPersonWithNonNullUserId(String courtUuid);
	public abstract void updatePersonForDeletedFlag(String uuid, byte isDeleted);
	
	
	/* Organizations 			*/
	//public abstract Object findOrganizationById(String uuid);
	public abstract Organizations findOrganizationById(String uuid);
	public abstract Organizations makePersistent(Organizations organization);
	public abstract List<Organizations> findAllOrganizations();
	
	/*
	 * PersonOrganizations
	 */
	public abstract PersonOrganizations makePersistent(PersonOrganizations po);

	/* Roles */
	public abstract Object findRoleById(String uuid);
	public abstract Roles makePersistent(Roles role);
	public abstract List<Roles> findAllRoles();
	
	/* 		CaseRecord Stuff 	
	 * 							*/
	public abstract CaseRecord findCaseRecordById(String uuid, String courtUuid);
	//returns List of the CaseRecord by status
	public abstract List<CaseRecord> findAllCaseRecordByStatus(int statusCode, String courtUuid);
	//returns List of the CaseRecord by caseType	
	public abstract List<CaseRecord> findAllCaseRecordByCaseType(int caseTypeCode, String courtUuid);
	//returns List of the CaseRecord by instantiationDateTime	
//	public abstract List<CaseRecord> findAllCaseRecordByInstantiationDateTime();
	//	Added for Paging of Imported Filings Queries
	public abstract List<Filing> findCaseFilingsByTypeAndStatusPaged(int typeCode,
			int statusCode, int pageIndex, int limit, String courtUuid);  
	public abstract int findNumberOfCaseFilingsByTypeAndStatus(int typeCode,
			int statusCode, String courtUuid);
	
	public abstract int findNumberOfCaseFilingsByTypeAndStatus(int typeCode,
			int statusCode1, int statusCode2, int statusCode3, int statusCode4, String courtUuid);
	
	
	//returns List of the New Case Records from all Case Types
	//public abstract List<CaseRecord> findNewCaseRecord();
	public abstract List<CaseRecord> findAllCaseRecordByTransmissionError(String courtUuid);
	
	 
	public abstract List<Filing> findCaseFilingsByTypeAndStatus(int typeCode, int statusCode, String courtUuid);
	public abstract List<Filing> findCaseFilingsByStatus(int statusCode, String courtUuid);
	public abstract List<Filing> findClearedCaseFilingsByType(int typeCode, String courtUuid);
	public abstract List<Filing> findCaseFilingsByType(int typeCode, String courtUuid);
	public abstract List<Filing> findErrorFilings();	
	public abstract List<Filing> findClearedCaseFilings(String courtUuid);
	//added by Sukhada on 03/22/07
	public abstract List<Filing> findProgressingFilings(String courtUuid);
	public abstract List<Filing> findExistingFilings(String courtUuid);
	public abstract List<Filing> findAttorneySideStatusFilings(String courtUuid);
	public abstract List<Filing> findCourtSideStatusFilings(String courtUuid);
	
	public abstract void removeCaseRecord(String uuid, String courtUuid);
	public abstract CaseRecord findCaseRecordByDocketID(String docketID, String courtUuid);
	//public abstract CaseRecord findCaseRecordByDocketID(String docketID,String courtUuid);
	public abstract void updateCaseRecordStatus(String uuid, CaseRecordStatus status, String courtUuid);
	public abstract void updateCaseRecordCourtTrackingID(String uuid, String docketID, String courtUuid);
	public abstract void updateImportedCaseRecord(String uuid, String docketID, int statusCode, String courtUuid);
	public abstract void updateRejectedCaseRecord(String uuid, String reason, int statusCode, String courtUuid);
	
	public abstract void updateCaseRecordForClearCase(String filingUuid,boolean clearInt, String courtUuid);
 
	
	public abstract List<CaseRecord> findAllClearedCaseRecords(boolean flag, String courtUuid);
	
	public abstract Object findCaseEventById(String uuid);	
	
	
	/* ******************************
	 * Court Event Queries
	 * ******************************
	 */
	/**
	 * Update the current Court Date, or if one is not set yet, create a new 
	 * entry for the Court Date.
	 * 
	 * @param caseRecordUuid  The UUID string of the associated Case Record
	 * @param courtDate  The date to update the Court Date to
	 * @param personUuid  The UUID string of the person updating the Court Date
	 */
	public abstract void updateCourtDate(String caseRecordUuid, Date courtDate, String personUuid);
	public abstract void updateCourtDateExtendedData(String caseRecordUuid, int dataID, String value);
	public abstract Date findCourtDate(String caseRecordUuid);
	
	//Court Hearing Negotiations
	public abstract void updateCourtHearingNegotiationStausToRejected(CourtHearingNegotiations chn);
	public abstract void updateCourtHearingNegotiationStausToAccepted(CourtHearingNegotiations chn);
	public abstract CourtHearingNegotiations findCourtHearingNegotiationsByCaseRecordUuid(String caseRecordUuid);

	//Documents
	public abstract Documents findDocumentsByInstanceAndCaseUuid(String docTypeCode, String caseUuid);
	public abstract List<Documents> findDocumentsByCaseUuid(String caseUuid);
	public abstract void updateDocumentStatus(String uuid, DocumentStatus docStatus);
	//added by Sukhada on 23rd Oct 06
	public abstract List<Documents> findDocumentsbyMaxVersion(String caseRecordUuid);
	public abstract List<Documents> getPDFDocuments(String caseRecordUuid);
	
	public abstract Documents makePersistenet(Documents document);
	
	//CaseRecord History
	public abstract void addCaseRecordHistory(String caseRecordUuid, int  eventTypeCode, Person person, String courtUuid,String comments);
	public abstract void addCaseRecordHistory(String caseRecordUuid, String courtUuid,
			int eventTypeCode, Person person,String comments);
	public abstract List<CaseRecordHistory> findHistoryByCaseRecordID(String caseUuid, String courtUuid);
	
	/******************** Angela added for GAJE_DataModel ******************************************/
	//Court
	public abstract Court findCourt(String courtUuid);
	//public abstract Organizations findOrganization(String courtUuid);
	
	//CaseRecord
	public abstract CaseRecord insertCaseRecord(CaseRecord cr, String courtUuid);
	
	//Person
	public abstract Person findPersonByName(String first, String middle, String last);
	public abstract Person insertPerson(Person p);
	public abstract Person findPersonbyID(String personID);
	
	//ParticipantRelationship
	public abstract ParticipantRelationship findParticipantRelationship(int id);
	
	// PersonParticipants
	public abstract PersonParticipants insertPersonParticipants(PersonParticipants pp);
	
	//AddressType
	public abstract AddressType findAddressType(int id);
	
	// PersonAddress
	public abstract PersonAddress insertPersonAddress(PersonAddress address);
	/**
	 * Method to pull back the PersonAddress object specified by the person
	 * and the address UUID
	 * 
	 * @param p person to find the address of
	 * @param addressUuid UUID of the address to match
	 * @return PersonAddress Object populated with the desired address
	 */
	public abstract PersonAddress findPersonAddress(Person p, String addressUuid);

	// Attorney
	/**
	 * @deprecated This method can not be used when an attorney files into multiple courts
	 */
	@Deprecated
	public abstract Attorney findAttorneyByBarID(String barID);
	public abstract void insertAttorney(Attorney att);
	
	//Organizations
	public abstract Organizations findOrganizationByName(String orgName);
	public abstract void insertOrganizations(Organizations org);
	
	//orgParticipants
	public abstract void insertOrgParticipants(OrgParticipants orgParticipants);
	
	//organizationAddress
	public abstract void insertOrganizationAddress(OrganizationAddress oa);
	public abstract OrganizationAddress findOrgAddress(Organizations org, String streetAddressText);

	//court event
	public abstract void insertCourtDate(CourtEvents event);
	
	//court event type
	public abstract CourtEventType findCourtEventType(Integer typeCode);
	
	//case record history
	public abstract void insertCaseRecordHistory (CaseRecordHistory crh);
	
	//case record event type
	public abstract CaseRecordEventType findCaseRecordEventType (Integer eventTypeCode);

	//documents
	public abstract void insertDocuments(Documents doc);
	
	//document type
	public abstract DocumentType findDocumentType(String typeDesc);
	
	//public abstract DocumentType findDocumentTypeByCode(String code);
	
	//public abstract void  updateXslContent(String code, byte[]xslContent);
	
	//public abstract List<DocumentType> findDocumentTypesByAliasType();
	public abstract List<DocumentInstance> findDocumentInstanceByAliasType();
	
	//document status
	public abstract DocumentStatus findDocumentStatus(Integer statusCode);
	
	
	//Filing Search
	public abstract List<FilingSearch> search(String fullText);
	
	//	filingAudit
	public abstract void insertFilingSearch(String docText, String docTitle, String docketID, String caseRecordUuid) ;
	public abstract void insertFilingAudit(FilingAudit fa);
	
	//Profile
	public abstract Profile makePersistenet(Profile profile);
	
	//Signatures
	public abstract Signatures makePersistent(Signatures signatures);
    public abstract void insertSignature(Signatures sig); 
    public abstract void insertCourtSeal(CourtSeal courtSeal); 
    // added by M Alexandrou
    public abstract List<Signatures> findSignaturesByDocumentsUuid(String docUuid);
	public abstract boolean isSignaturesByDocumentsUuidAndPersonUuid(String docUuid, String personUuid);
	//CourtSeal
	public abstract CourtSeal findCourtSealByDocumentID(String documentID);
	public abstract CourtSeal makePersistent(CourtSeal courtSeal);
	
	//Counter
	public abstract Counter makePersistent(Counter counter);
	public abstract Counter getCounter();
	public abstract void updateCounter(String counterUuid, int newCounterValue);
	
	//CounterPerSigner
	public abstract void makePersistent(CounterPerSigner counterPerSigner);
	public abstract void insertCounterPerSigner(CounterPerSigner counterPerSigner);
	public abstract CounterPerSigner findCounterPerSignerBySignerUuid(String uuid);
	public abstract String findCounterUuidBySignerUuid(String uuid);
	//public abstract void updateCounterPerSigner(String counterUuid, int counterValue, Date dateOfLastSignature, String personUuuid);
	public abstract void updateCounterPerSigner(String personUuid);
	public abstract boolean isSigner(String uuid);
	public abstract FilingAudit getFilingAudit(String crUuid);

	//documentType
	public abstract List<String> getAllDescriptionsOfDocumentType();
	public abstract DocumentType findDocTypeByDescription(String description);
	
	//documents
	public abstract Documents makePersistent(Documents document);
	public abstract List<Documents> findDocumentsByDocStatusCode(int code);
	/**
	 * This query grabs all documents in the database.
	 * 
	 * @param record the row to be pulled back.
	 * @return a list of all documents in the database.
	 */
	public abstract List<Documents> findAllDocuments(int record);
	
	public abstract CaseRecordType findCaseRecordTypeByCode(int code);
	public abstract CaseRecordStatus findCaseRecordStatusByCode(int code);
	public abstract Court findCourtByUuid(String uuid);
	
	//documentSigConfig
	public abstract DocumentSigConfig findCoordinatesByCodeRole(String personRole, String documentCode);

	public abstract CaseRecord findCaseRecordByExternalCaseRecordUuidAndExternalCaseTypeCode(String externaCaseRecordUuid, int ocssCaseTypeCode, String courtUuid);
	//public abstract void insertExternalCaseRecordToCaseRecord(String externalCaseRecordUuid, CaseRecord caseRecord, int ocssCaseTypeCode);
	public abstract boolean isExternalCaseRecordUuidAndExternalCaseTypeCode(String externalCaseRecordUuid, int externalCaseTypeCode, String courtUuid);
	public abstract void insertExternalCaseRecordIntoCaseRecordTable(String caseRecordUuid, String externalCaseRecordUuid, int externalCaseTypeCode, String courtUuid);
	
	public abstract void insertCourtEvents(CourtEvents courtEvent);
	
	public abstract List<Filing> findAllFilingsByTypeForClerk(int typeCode, String courtUuid);
	
	public abstract List<Filing> findAllFilingsByTypeForJudge(int typeCode, String courtUuid);
	
	/**
	 * @deprecated Replaced by {@link LegalPreparer#getAttorney()}
	 * @param personUuid
	 * @return The attorney object.
	 */
	@Deprecated
	public abstract Attorney findAttorneyByLegalPreparerUuid(String personUuid);
	
	/** 
	 * @depcrated This method is depracated because 
	 * 	it fails when multiple agents file with the same attorney.
	 *  Replaced by {@link #findLegalPreparerByPersonAndOrg(Person, String)} and {@link LegalPreparer#getAttorney()}
	 */	
	@Deprecated
	public abstract Person findPersonByAttorneyUuid(String attorneyUuid);
	
	/**
	 * Method to pull attorney information knowing that the person is an attorney.
	 * 
	 * For use with the Attorney module.
	 * 
	 * @param person - The attorney to find out the information on.
	 * @return A populated Attorney model object.
	 * @deprecated This does not work with attornies who file into multiple courts
	 */
	@Deprecated
	public abstract Attorney findAttorneyByPerson(Person person);
	public abstract void removeDocumentFromListByCaseRecordUuidAndDocumentInstanceCode(String caseRecordUuid, String documentTypeCode);
	/**
	 * @param doc
	 */
	public abstract void deleteDocument(Documents doc);
	
	public abstract void enableDocDeleteFlag(Documents doc);

	
	//LdapDirectoryPerson
	public abstract LdapDirectoryPerson findLdapDirectoryByPerson(Person person);
	//DocumentPackage
	public abstract DocumentPackage findPackageNameByUuid(String uuid);
	public abstract DocumentPackage findDocumentPackageByName(String name);
	//DocPageRange
	public abstract List<DocPageRange> findAllPageRangeByPackageUuid(DocumentPackage dp);
	public abstract DocumentType findDocTypeByRangePackageUuid(int start, int end, DocumentPackage dp);
	public abstract DocumentType findDocTypeByUuid(String uuid);
	
	public abstract List<Filing> findClearedCaseFilingsAgentSide(String courtUuid) ;
	
	public abstract List<Filing> findClearedCaseFilingsClerkSide(String courtUuid) ;
	/**
	 * @param caseRecord
	 */
	public abstract List<PersonParticipants> getPersonParicipant(CaseRecord caseRecord);
	/**
	 * @param person
	 */
	public abstract void deletePerson(Person person);
	/**
	 * @param record
	 */
	public abstract void deletePersonParticipants(PersonParticipants pp);
	/**
	 * @param personParticipant
	 * @return
	 */
	public abstract List<CaseRecord> findCaseRecordsByPerson(Person personParticipant);
	/**
	 * @param record
	 */
	public abstract void deleteCourtEvent(CaseRecord record);
	public abstract void deleteCaseRecord(String caseUuid, String courtUuid);
	/**
	 * @param docType
	 * @return
	 */
	public abstract DocumentInstance findDocumentInstanceByCode(int docType);
	/**
	 * @param code
	 * @return
	 */
	public abstract LocalCaseCategory findLocalCaseCategoryByCourtandCode(Court court, String cmsCode);
	/**
	 * @return
	 */
	public abstract LocalCaseDivision findLocalCaseDivisionByCourtandCode(Court court, String cmsCode);
	/**
	 * @param code
	 * @return
	 */
	public abstract LocalCaseFilingType findLocalCaseFilingTypeByCourtandCode(Court court, String cmsCode);
	/**
	 * @param code
	 * @return
	 */
	public abstract LocalCaseType findLocalCaseTypeByCourtandCode(Court court, String cmsCode);
	/**
	 * @param court
	 * @return
	 */
	public abstract List<DocumentInstance> findDocumentInstanceByAliasType(Court court);
	/**
	 * @param court
	 * @return
	 */
	public abstract List<DocumentPackage> findDocumentPackageByAliasType(Court court);
	/**
	 * @param n
	 * @return
	 */
	public abstract DocumentSigConfig getDocumentSigConfig(int documentCode, Person personSigned);
	
	public abstract LocalParticipantRelationship findLocalParticipantRelationship(Court court, int participantRelationshipCode);
	
	public abstract LocalCourtEventType findLocalCourtEventType(Court court, int courtEventTypeCode);
	
	public abstract Signatures findSignatureFromSignatureTrackingID(String sigTrackingId);
	
	public abstract Date findAttorneySubmissionDate(String caseRecordUuid);
	
	//public abstract CaseRecord findCaseRecordByDocketIDAndCourtUuid(String docketID, String courtUuid);
	
	public abstract DocumentInstance findGenericDocumentInstance(String localCode, Court court);
	// aded by Michael Alexandrou
	public abstract void insertIntoCaseRecordIdExternalCaseRecordNumber(CaseRecord caseRecord, String externalCaseRecordNumber, Organizations org);
	public abstract List<CaseRecord> findCaseRecordListByExternalCaseRecordNumber(String externalCaseRecordNummber);
	public abstract List<Filing> findFilingsByExternalCaseRecordNumber(String externalCaseRecordNumber, String courtUuid);
	/**
	 * A method to retrieve a list of all external case record numbers for a 
	 * particular court case record.
	 * 
	 * @param caseRecordUuid
	 * @return A list of external case record number objects, 
	 * 	List<CaseRecordExternalCaseRecordNumber>
	 */
	public abstract List<CaseRecordIdExternalCaseRecordNumber> findExternalCaseRecordNumbers(String caseRecordUuid);
	/**
	 * @param i
	 * @param j
	 * @param k
	 * @param l
	 * @return
	 */
	//public abstract List<Filing> findCaseFilingsByTypeAndStatus(int typeCode, int statusCode1, int statusCode2, int statusCode3 );
	//added by Michael Alexadrou
	public abstract Person findPersonByHashedSSN(String ssn);
	
	//Added by Frank
	public abstract List<Filing> findCaseFilingsByPerson(String firstName, String middleName, String lastName, boolean defendantSearch, String courtUuid);
	// TODO - Need to actually add text into the Java Docs comments to describe
	// what the methods do and what the variables are.
	/**
	 * @param caseType
	 * @return
	 */
	public abstract int findNumberOfCaseFilingsByType(int caseType, String courtUuid);
	/**
	 * @param caseType
	 * @param startRow
	 * @param pageSize
	 * @return
	 */
	public abstract List<Filing> findCaseFilingsByTypePaged(int caseType, int startRow, int pageSize, String courtUuid);
	/**
	 * @param caseType
	 * @param status1
	 * @param status2
	 * @param status3
	 * @param status4
	 * @param startRow
	 * @param pageSize
	 * @return
	 */
	public abstract List<Filing> findCaseFilingsByTypeAndStatusPaged(int caseType, int status1, int status2, int status3, int status4, int startRow, int pageSize, String courtUuid);
	public abstract List<Filing> findCaseFilingsByTypeAndStatus(int i, int j, int k, int l, int m, String courtUuid);
	public abstract List<Filing> findFilingByCaseTrackingId(String caseTrackingId, String courtUuid);
	public abstract void insertIntoPersonIdHashedSSN(String personUuid, String hashedSSN);
	public abstract  List<Person> findPersonListByNameAndByDOB(String firstName, String middleName, String lastName, Date dateOfBirth);
	/**
	 * @param typeCode
	 * @param startRow
	 * @param pageSize
	 * @return
	 */
	public abstract List<Filing> findAllFilingsByTypeForClerkPaged(int typeCode, int startRow, int pageSize, String courtUuid);
	/**
	 * @param typeCode
	 * @param startRow
	 * @param pageSize
	 * @return
	 */
	public abstract List<Filing> findAllFilingsByTypeForJudgePage(int typeCode, int startRow, int pageSize, String courtUuid);
	/**
	 * @param typeCode
	 * @return
	 */
	public abstract int findNumberOfCaseFilingsByTypeForClerk(int typeCode, String courtUuid);
	/**
	 * @param typeCode
	 * @return
	 */
	public abstract int findNumberOfCaseFilingsByTypeForAdmin(int typeCode, String courtUuid);
	/**
	 * @param typeCode
	 * @return
	 */	
	public abstract int findNumberOfCaseFilingsByTypeForJudge(int typeCode, String courtUuid);
	/**
	 * @param typeCode
	 * @return
	 */
	public abstract List<Filing> findAllFilingsByTypeForAdmin(int typeCode, String courtUuid);
	
	/**
	 * @param startingDate
	 * @param endingDate
	 * @param personLoginUuid
	 * @return
	 */
	public abstract List<Filing> findCaseFilingsForPastDays(Date startingDate, Date endingDate, String personLoginUuid, String courtUuid);
	/**
	 * @param addressCategoryCode
	 * @return
	 */
	public abstract AddressCategory findAddressCateory(
			int addressCategoryCode);
	/**
	 * @param addressTypeCode
	 * @param addressCategory
	 * @return
	 */
	public abstract AddressType findAddressType(int addressTypeCode,
			AddressCategory addressCategory);
	/**
	 * @param person
	 * @param addressType
	 * @return
	 */
	public abstract Address findAddress(Person person,
			AddressType addressType);
	/**
	 * Method to find if an address in the database matches the one being 
	 * checked.
	 * 
	 * @param address to be checked for matches
	 * @return Address from DB that matches the one in question
	 */
	public abstract Address findAddressExactMatch(Address address);
	/**
	 * @param instanciationDate
	 * @param submittedDate
	 * @param crSt
	 * @param crT
	 * @param c
	 * @param localCaseCategory
	 * @param localCaseDivision
	 * @param localCaseFilingType
	 * @param localCaseType
	 * @return
	 */
	public abstract CaseRecord createCaseRecord(Date instanciationDate,
			Date submittedDate, CaseRecordStatus crSt, CaseRecordType crT,
			Court c, LocalCaseCategory localCaseCategory,
			LocalCaseDivision localCaseDivision,
			LocalCaseFilingType localCaseFilingType, LocalCaseType localCaseType, String courtUuid);
	/**
	 * @param orgFound
	 * @param street1
	 * @return
	 */
	public abstract Organizations findOrganization(Organizations orgFound,
			String street1);
	/**
	 * @param addr
	 */
	public abstract void insertAddress(Address addr);
	/**
	 * @param p
	 * @param address
	 * @param personAddress
	 */
	public abstract void updateAddress( Address address,PersonAddress personAddress);
	/**
	 * Method to update the address association type of a person - address
	 * association.
	 * 
	 * @param addressUuid - UUID of address to updated
	 * @param addressType - Type of Address association to change to
	 * @return int statusCode <p>
	 *    <li> Status Codes
	 *    	<ul> 0 = Successful Execution
	 *      <ul> 1 = Error State
	 *   </li>
	 *   </p>
	 */
	public abstract int updatePersonAddressType(String personAddressUuid, 
			AddressType addressType);
	/**
	 * @param personHashedSSN
	 */
	public abstract void makePersistent(PersonHashedSSN personHashedSSN);
	
	/**
	 * Query to pull case filings that fall within a particular date range.
	 * @param startingDate
	 * @param endingDate
	 * @return List<String> - A list of case record uuid's that meet the criteria.
	 */
	public abstract List<String> findCaseFilingsWithinDateRange(Date startingDate, Date endingDate, String courtUuid);

	/**
	 * @param personSigner
	 * @param altSigFlag 
	 * @param visualCategory 
	 * @return
	 */
	public abstract VisualMark getVisualMark(Person personSigner, boolean altSigFlag, VisualMarkCategory visualCategory);
	/**
	 * @param personSigner
	 * @param altSigFlag
	 * @return
	 */
	public abstract List<VisualMark> getVisualMarkList(Person personSigner,
			boolean altSigFlag,  VisualMarkCategory visualCategory);
	/**
	 * @param visualCategoryCode
	 * @return
	 */
	public abstract VisualMarkCategory getVisualCategory(int visualCategoryCode);

	
	/**
	 * This query returns a local document code for a given court and a given document instance
	 * @param documentInstanceCode
	 * @param courtUuid
	 * @return
	 */
	public abstract DocumentLocalCode findDocumentLocalCodeFromDocumentInstanceCode(int documentInstanceCode);
	
	/**
	 * This query returns the number of documents of a case record in GAJE system that are imported in the local cms
	 * This number is needed in order to import an additional document
	 * @param caseRecord
	 * @return number of documents already imported into CMS of aC case record 
	 */
	public int findTheNumberOfDocumentsAlreadyImportedIntoCMSOfACaseRecord(CaseRecord caseRecord);
	/**
	 * This method gets the list of the documents type for given document category
	 * @param docCategoryCode
	 * @return
	 */
	public abstract List<DocumentType> getDocumentTypeList(	int docCategoryCode);
	
	public abstract LdapDirectoryOrganization findLdapDirectoryByOrganization(Court court);
	//public abstract LdapDirectoryOrganization findLdapDirectoryByOrganization(Organizations court);
	public abstract PersonAddress findPersonAddress(Person personFound);
	
	/**
	 * get the participant(s) in a case with a specific participantRelationshipCode
	 * @param caseRecord 
	 * @param participantRelationshipCode
	 * @return list of participants
	 */
	public abstract List<PersonParticipants> getPersonParticipantByParticipantRelationshipCode(CaseRecord caseRecord, int participantRelationshipCode);
	
	

	/**
	 * get the initiating organization(s) in a case
	 * @param caseRecord
	 * @return the list of initiating organizations
	 */
	public abstract List<OrgParticipants> getOrgParticipantInitiatingParty(CaseRecord caseRecord);
	
	//added by Bhawana
	
	//Case Statistics
	public abstract int countCaseRecords(String courtUuid);
	public abstract int countContemptCases(String courtUuid);
	public abstract int countEstablishedCases(String courtUuid);
	public abstract int countLocalCases(String courtUuid);

	public abstract List<CaseRecordsCountPerDay> countCasesByDay(String courtUuid);
	public abstract  List <CaseRecordsCountPerMonth> countCasesByMonth(String courtUuid);
	// Person Statistics
	
	/**
	 * Get a list of strings of descriptions of the case record statuses
	 * One use of this list is in the creation of UISelectItem uiItems to populate a list box.
	 * A user can then select a description for possible modification of the status of a case
	 * @return a list of descriptions
	 */
	public abstract List<String> getCaseRecordStatusDescriptionList();
	
	public abstract int findCaseRecordStatusCode(String caseRecordStatusDescription);
	
	public abstract int findDocumentStatusCode(String documentStatusDescription);
	
	/**
	 * change the status of a case record
	 * @param caseReocrd
	 * @param caseRecordStatusCode
	 */
	public abstract void UpdateCaseRecordByStatus(CaseRecord caseReocrd, CaseRecordStatus caseRecordStatus, String courtUuid);
	
	public abstract int countChildren();
	public abstract int countDefendents();
	
	//Documents Statistics
	/**
	 * Get a list of strings of descriptions of a document statuses
	 * One use of this list is in the creation of UISelectItem uiItems to populate a list box.
	 * A user can then select a description for possible modification of the status of a document
	 * @return a list of descriptions
	 */
	public abstract List<String> getDocumentStatusDescriptionList();
	
	/**
	 * @param docUuid
	 * @param docStatus
	 * One possible use of this method is from the admin module where an authorized 
	 * administrator changes the status of a document
	 */
	public abstract void UpdateDocumentByStatus(String docUuid, DocumentStatus docStatus);
	
	/**
	 * @param typeCode
	 * @return the filings that are flagged as cleared
	 * One possible use of this method is from the admin module where an authorized administrator
	 * sees all the cleared filings and decides to restore one or more of them
	 */
	public abstract List<Filing> findAllClearedFilings(int typeCode, String courtUuid);
	
	/**
	 *  update case filing by the clear filing flag 
	 *  @param caseRecordUuid
	 *  @param clearFilingFlag
	 */
	public abstract void UpdateFilingByClearFilingFlag( int typeCode, String caseRecordUuid, boolean clearFilingFlag, String courtUuid);
	
	/**
	 * Method to determine how many rows are possible to be returned by a query 
	 * for case filings that are cleared but not deleted and not archived
	 * 
	 * @param typeCode
	 * @return int Count of number of rows
	 */
	public abstract int findNumberOfClearedFilingsByType(int typeCode, String courtUuid);
	
	/**
	 * Gets a list of cases of the type of the passed case record event type
	 * codes from the database and sorts the list by either instantiation date
	 * or last event date in ascending or descending order.
	 * 
	 * @param caseType the type of case.
	 * @param statusCode1 a case record event type code.
	 * @param statusCode2 a case record event type code.
	 * @param statusCode3 a case record event type code.
	 * @param statusCode4 a case record event type code.
	 * @param statusCode5 a case record event type code.
	 * @param desc a flag indicating if the ordered column is descending.
	 * @param orderByEvt a flag indicating if the column is ordered by last event date.
	 * @param personalCases a flag indiciating if only the cases the user has
	 * worked on should show or not and contains the uuid, if applicable.
	 * @return a list of cases.
	 */
	public abstract List<Filing> sortFiling(int typeCode, int statusCode1,
			int statusCode2, int statusCode3, int StatusCode4, int statusCode5,
			boolean desc, boolean orderByEvt, String personalCases, String courtUuid);
	
	/**
	 * Gets a list of cases of the type of the passed case record event type
	 * codes from the database and sorts the list by either instantiation date
	 * or last event date in ascending or descending order.
	 * 
	 * @param caseType the type of case.
	 * @param statusCode1 a case record event type code.
	 * @param statusCode2 a case record event type code.
	 * @param statusCode3 a case record event type code.
	 * @param statusCode4 a case record event type code.
	 * @param statusCode5 a case record event type code.
	 * @param desc a flag indicating if the ordered column is descending.
	 * @param orderByEvt a flag indicating if the column is ordered by last event date.
	 * @param startRow a variable to handle the paging of the list.
	 * @param pageSize a variable to handle the paging of the list.
	 * @param personalCases a flag indiciating if only the cases the user has
	 * worked on should show or not and contains the uuid, if applicable.
	 * @return a list of cases.
	 */
	public abstract List<Filing> sortFilingPaged(int typeCode, int statusCode1,
			int statusCode2, int statusCode3, int statusCode4, int statusCode5,
			boolean desc, boolean orderByEvt, int startRow,
			String personalCases, int pageSize, String courtUuid);
	
	/**
	 * Gets a list of cases of the type of the passed case record event type
	 * codes from the database and sorts the list by either instantiation date
	 * or last event date in ascending or descending order.
	 * 
	 * @param caseType the type of case.
	 * @param statusCode1 a case record event type code.
	 * @param statusCode2 a case record event type code.
	 * @param statusCode3 a case record event type code.
	 * @param statusCode4 a case record event type code.
	 * @param desc a flag indicating if the ordered column is descending.
	 * @param orderByEvt a flag indicating if the column is ordered by last event date.
	 * @param personalCases a flag indiciating if only the cases the user has
	 * worked on should show or not and contains the uuid, if applicable.
	 * @return a list of cases.
	 */
	public abstract List<Filing> sortFiling(int typeCode, int statusCode1,
			int statusCode2, int statusCode3, int StatusCode4,
			boolean desc, boolean orderByEvt, String personalCases, String courtUuid);
	
	/**
	 * Gets a list of cases of the type of the passed case record event type
	 * codes from the database and sorts the list by either instantiation date
	 * or last event date in ascending or descending order.
	 * 
	 * @param caseType the type of case.
	 * @param statusCode1 a case record event type code.
	 * @param statusCode2 a case record event type code.
	 * @param statusCode3 a case record event type code.
	 * @param statusCode4 a case record event type code.
	 * @param desc a flag indicating if the ordered column is descending.
	 * @param orderByEvt a flag indicating if the column is ordered by last event date.
	 * @param startRow a variable to handle the paging of the list.
	 * @param pageSize a variable to handle the paging of the list.
	 * @param personalCases a flag indiciating if only the cases the user has
	 * worked on should show or not and contains the uuid, if applicable.
	 * @return a list of cases.
	 */
	public abstract List<Filing> sortFilingPaged(int typeCode, int statusCode1,
			int statusCode2, int statusCode3, int statusCode4,
			boolean desc, boolean orderByEvt, int startRow,
			String personalCases, int pageSize, String courtUuid);
	
	/**
	 * Method to get all cases of a certain case type and of two certain statuses
	 * In the application frequently we query the data base by the "filing" view that includes info 
	 * from the participants table also. That results in the application to break if a case record is created 
	 * with no participants
	 */
	public abstract List<CaseRecord> findAllCaseRecordsByCaseTypeAndStatus(int caseTypeCode, int statusCode1, int statusCode2, String courtUuid);
	
	/**
	 * @param typeCode
	 * @return
	 */
	public abstract int findNumberOfAllCaseRecordsByCaseTypeAndStatus(int typeCode, int statusCode1, int statusCode2, String courtUuid);

	public abstract int countDocuments();
	public abstract List<DocumentsCountPerMonth> countDocumentsByMonth();
	public abstract List<DocumentsCountByType> countDocumentsByType();
	//public abstract int countDocumentsByCategoryExcludingDataFiles();
	//public abstract int countNumberOfDocumentsByCategoryAndTypeExcludingDataFiles();
//	public abstract int countDocumentsByMonth();
	
	//Signature Statistics
	public abstract int countSignatures();
	public abstract int CountSignaturesByAttorney();
	public abstract int countSignatureByCourtClerk();
	public abstract int countSignaturesByJudge();
	//Filing Statistics
	public abstract int countFilings(String courtUuid);
	public abstract int countProcessedFiling(String courtUuid);
	
   //Dismissed Case Report
	public abstract List<DismissedCases> findDismissedCases(String courtUuid);
	public abstract List<DismissedCasesPerMonth> countDismissedCasesPerMonth(String courtUuid);
	/**
	 * This method returns the text document form the caseRecord
	 * @param caseUuid
	 * @return
	 */
	public abstract Documents getTextDocument(String caseUuid);
	public abstract List<Filing> findCaseFilingsByPerson(String firstName,
			String middleName, String lastName, String courtUuid);
	
	/**
	 * This method returns a set number of DocumentBinaries at one time.
	 * 
	 * @param rowNumber the row number which to start the batch lookup.
	 * @return a list of documentBinaries.
	 */
	public abstract List<DocumentBinaries> findAllDocumentBinaries(int rowNumber);
	
	/**
	 * This method updates the path column of the documentBinaries table for a
	 * particular entry.
	 * 
	 * @param uuid the uuid of the documentBinaries entry to update.
	 * @param path the path at which the document binary can be found.
	 */
	public abstract void updateDocumentBinaryPath(String uuid, String path);
	
	/**
	 * This method returns a documentBinary entry that belongs to the passed
	 * uuid.
	 * @param uuid the uuid of the documentBinary being looked for.
	 * @return the documentBinary belonging to the passed uuid.
	 */
	public abstract DocumentBinaries findDocumentBinaryByUuid(String uuid);
	
	/**
	 * This method inserts an entry into the documentBinaries table.
	 * 
	 * @param uuid the uuid of the documentBinaries entry.
	 * @param metaDoc the document of corresponding documents entry.
	 * @param version the version of the document.
	 * @param path the path where the document binary can be found on the file
	 * system.
	 */
	public abstract void insertDocumentBinaries(String uuid, Documents metaDoc,
			int version, String path);
	
	/**
	 * This method returns the number of the most current version of a document
	 * given the document uuid.
	 * 
	 * @param uuid the document uuid to search for.
	 * @return the most current version number.
	 */
	public abstract int getCurrentVersion(String docUuid);
	
	/**
	 * Saves the documentBinaries entry in the database.
	 * 
	 * @param binary the databaseBinaries entry to save.
	 */
	public abstract void makePersistent(DocumentBinaries documentBinaries);
	
	/**
	 * Updates the OCSS case number for the given case
	 * 
	 * @param uuid
	 * @param newExternalCaseNumber
	 */
	public abstract void updateExternalCaseNumber(String uuid, String newExternalCaseNumber);
	public abstract List<ParticipantRelationship> getAllParticipantRelationshipCodes();
	Person findAttorneyByBarIDAndOrgAsPerson(String barID, String courtUuid);
	public abstract PersonOrganizations findPersonOrganizationByCourtAndPerson(
			Person personFiler, String courtUuid);
	public abstract LegalPreparer findLegalPreparerByPersonAndOrg(
			Person personFiler, String uuid);
	public abstract Attorney getNullAttorney(Organizations organization);
	public abstract String getBarID(Person person, Court court);
	public abstract List<PersonParticipants> getPersonParticipantByPerson(
			Person personParticipant);
	
	public abstract String generateDocketId(String prefix, String courtUuid);
	public abstract void updateCaseRecord(CaseRecord caseRecord,
			String courtUuid);
	public abstract List<DocumentInstance> findAllDocumentsByCourt(
			String courtUuid);
	public abstract void insertDocumentPackage(DocumentPackage doc,
			ArrayList<DocPageRange> pageRanges);
	
	/**
	 * Checks to see if the civil action number given is in the database already.
	 * @param cvNumber
	 * @param courtUuid
	 * @return true if it exists, false if it doesn't
	 */
	public abstract boolean findCivilActionNumber(String cvNumber,
			String courtUuid);
	public abstract List<CourtSeal> getDuplicateCourtSealList(
			String documentUuid);
	public abstract int countDocumentAssociations(String documentUuid);
	public abstract CourtSeal findCourtSealByID(int rowNumber);
	public abstract List<LegalPreparer> getLegalPreparers(Person personFiler,
			Organizations organization);
	public abstract PersonOrganizations findPersonOrganization(String id);
	public abstract List<CaseRecordAction> getCaseRecordActionsByCaseType(int i);
	public abstract CaseRecordAction getCaseRecordActionsById(
			int externalCaseCategoryCode);
	
	public abstract List<DocumentPackage> findDocumentPackageByCaseRecordAction(Court court,CaseRecordAction cra);
	
	/**
	 * Method to Generate the Report for Each Court
	 * @param statusCode
	 * @param courtUuid
	 * @param startEventDateTime
	 * @param endEventDateTime
	 * @return
	 */
	public abstract List<Filing> findAllCaseRecordByStatusCodeandLatestEventDateTime(int statusCode,String courtUuid,Date startEventDateTime,Date endEventDateTime);
	public abstract List<Filing> findAllCaseRecordByStatusandCreatedDate(int statusCode,String courtUuid,Date startInstantiationDateTime,Date endInstantiationDateTime);
	public abstract List<Filing> findAllCaseRecordByEventCodeandLatestEventDateTime(int eventCode,String courtUuid,Date startEventDateTime,Date endEventDateTime);
	public abstract List<Filing> findAllCaseRecordByEventCodeandEventDateTime(int eventCode,String courtUuid,Date startEventDateTime,Date endEventDateTime);

	
	public abstract SignatureImage findImageByUuid (String uuid);

	public List<CaseRecordStatus> getCaseRecordStatusList();			

	
 }